home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / uim / deprecated-util.scm < prev    next >
Encoding:
Text File  |  2010-11-07  |  4.2 KB  |  143 lines

  1. ;;; util.scm: Deprecated utility functions for uim.
  2. ;;;
  3. ;;; Copyright (c) 2003-2009 uim Project http://code.google.com/p/uim/
  4. ;;;
  5. ;;; All rights reserved.
  6. ;;;
  7. ;;; Redistribution and use in source and binary forms, with or without
  8. ;;; modification, are permitted provided that the following conditions
  9. ;;; are met:
  10. ;;; 1. Redistributions of source code must retain the above copyright
  11. ;;;    notice, this list of conditions and the following disclaimer.
  12. ;;; 2. Redistributions in binary form must reproduce the above copyright
  13. ;;;    notice, this list of conditions and the following disclaimer in the
  14. ;;;    documentation and/or other materials provided with the distribution.
  15. ;;; 3. Neither the name of authors nor the names of its contributors
  16. ;;;    may be used to endorse or promote products derived from this software
  17. ;;;    without specific prior written permission.
  18. ;;;
  19. ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
  20. ;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. ;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. ;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
  23. ;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. ;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. ;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. ;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. ;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. ;;; SUCH DAMAGE.
  30.  
  31. ;; To find deprecated procedure invocation, type as follows (or type
  32. ;; it into M-x grep). But replacement of the deprecated procedures are
  33. ;; not necessary for uim 1.5. Keeping in mind avoiding the procedures
  34. ;; on writing a new code is enough.  -- YamaKen 2007-07-11
  35. ;;
  36. ;; $ egrep '\((string-list-concat|string-find|truncate-list|list-head|nconc|string-to-list|symbolconc|nth|nthcdr|copy-list|digit->string|puts|siod-print|print|feature\?|uim-symbol-value-str)\b' *.scm
  37.  
  38. (require-extension (srfi 1 34))
  39.  
  40.  
  41. ;; TODO: rewrite list processing with 'string-append'
  42. (define string-list-concat
  43.   (lambda (lst)
  44.     (apply string-append (reverse lst))))
  45.  
  46. ;; TODO: replace with 'member'
  47. (define string-find
  48.   (lambda (lst str)
  49.     (member str lst)))
  50.  
  51. ;; TODO: replace with 'take'
  52. (define truncate-list
  53.   (lambda (lst n)
  54.     (guard (err
  55.         (else #f))
  56.       (take lst n))))
  57.  
  58. ;; TODO: replace with 'take'
  59. (define list-head take)
  60.  
  61. (define nconc
  62.   (lambda (lst obj)
  63.     (if (null? lst)
  64.     obj
  65.     (begin
  66.       (set-cdr! (last-pair lst) obj)
  67.       lst))))
  68.  
  69. ;; TODO: rewrite list processing with 'string->list'
  70. ;; split EUC-JP string into reversed character list
  71. (define string-to-list
  72.   (lambda (s)
  73.     (with-char-codec "EUC-JP"
  74.       (lambda ()
  75.     (map! (lambda (c)
  76.         (let ((str (list->string (list c))))
  77.           (with-char-codec "ISO-8859-1"
  78.             (lambda ()
  79.               (%%string-reconstruct! str)))))
  80.           (reverse! (string->list s)))))))
  81.  
  82. ;; TODO: replace with symbol-append
  83. ;;
  84. ;; Since symbol-append is not yet defined at here, enclose into closure.
  85. ;;(define symbolconc symbol-append)
  86. (define symbolconc
  87.   (lambda args
  88.     (apply symbol-append args)))
  89.  
  90. ;; TODO: replace with list-ref
  91. (define nth
  92.   (lambda (k lst)
  93.     (list-ref lst k)))
  94.  
  95. ;; TODO: replace with list-tail
  96. (define nthcdr
  97.   (lambda (k lst)
  98.     (guard (err
  99.         (else #f))
  100.       (list-tail lst k))))
  101.  
  102. ;; TODO: replace with list-copy of SRFI-1
  103. (define copy-list
  104.   (lambda (lst)
  105.     (append lst '())))
  106.  
  107. ;; TODO: replace with number->string
  108. (define digit->string
  109.   (lambda (n)
  110.     (and (number? n)
  111.          (number->string n))))
  112.  
  113. ;;
  114. ;; SIOD compatibility
  115. ;;
  116.  
  117. ;; TODO: replace with 'display'
  118. (define puts display)
  119.  
  120. ;; TODO: replace with 'writeln'
  121. (define siod-print
  122.   (lambda (obj)
  123.     (write obj)
  124.     (newline)))
  125.  
  126. ;; TODO: replace with 'writeln'
  127. (define print siod-print)
  128.  
  129. ;; TODO: replace with 'provided?'
  130. (define feature?
  131.   (lambda (sym)
  132.     (provided? (symbol->string sym))))
  133.  
  134. ;; for backward compatibility
  135. (define uim-symbol-value-str
  136.   (lambda (sym)
  137.     (let ((val (if (symbol-bound? sym)
  138.            (symbol-value sym)
  139.            "")))
  140.       (if (symbol? val)
  141.       (symbol->string val)
  142.       val))))
  143.